home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <string.h>
- #include <glib.h>
- #include <strlib.h>
- #include "land.h"
- #include "init.h"
-
- /* #include "..\lib.h" */
-
- char workdir[32];
- unsigned char huge WAREA[(long)205824]; /* 512*2+512*400 作業用ワークエリア */
-
- void mttl()
- {
- line(0,0, 639, 22, PSET, col7, 2, 0xffff);
- line(0,0, 639, 22, PSET, col1, 1, 0xffff);
- symbol_(6, 4, "観測衛星画像解析", 2,1, col0, 0,PSET);
- symbol(472, 4, "Ver. 0.92 by Garnet", 1,2, col0, 0,PSET);
- symbol_(4, 2, "観測衛星画像解析", 2,1, col15,0,PSET);
- symbol(470, 2, "Ver. 0.92 by Garnet", 1,2, col15, 0,PSET);
- }
-
- /* 作業領域内容表示 */
- void waexp()
- {
- unsigned ddadr[2];
- unsigned char page;
- char buf[30175]; /* (397*152+7)/8*4 */
- int x, y, com;
- int mx, my;
- FILE *fp;
- char wname[64], swk[80], swk2[80], swk3[80];
- unsigned char headblk[2][512];
- size_t bsize, bn;
- int i, j;
-
- x = 60; y = 65;
- page = 0;
- BSETDATAADR(ddadr, buf);
- GDS_getBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151);
-
- helpbox( x, y, x+390, y+140, "作業領域概要\x095\x05c示");
- /* 表 */
-
- for (i = 1; i <= 3; i++) {
- j = x + 10 + 110*(i-1);
- sprintf(swk, "作業領域 %1d", i);
- msgset(j, y+25, swk, col0);
-
- /* work area open */
- sprintf(wname, "%s\\warea%1d.lnd", workdir, i);
- if ((fp = fopen(wname, "rb")) == NULL) {
- continue;
- }
- bsize = 512; bn = 1;
- if (fread( headblk[0], bsize, bn, fp) != bn) {
- fclose(fp); continue;
- }
- if (fread( headblk[1], bsize, bn, fp) != bn) {
- fclose(fp); continue;
- }
- strmid(swk, headblk[0]+16, 1, 15); /* original or calc */
- msgset2(j, y+45, swk, col0);
-
- sprintf(swk, "[%sL-%sL]", strmid(swk2, headblk[1], 1, 4), strmid(swk3, headblk[1]+4, 1, 4));
- msgset2(j, y+55, swk, col0);
-
- sprintf(swk, "[%sP-%sP]", strmid(swk2, headblk[1]+16, 1, 4), strmid(swk3, headblk[1]+20, 1, 4));
- msgset2(j, y+65, swk, col0);
-
- strmid(swk, headblk[0]+32, 1, 15); /* band num */
- msgset2(j, y+75, swk, col0);
-
- strmid(swk, headblk[1], 89, 7); /* date */
- msgset2( j, y+85, swk, col0);
- strmid(swk, headblk[1], 97, 9); /* wrs seen sentor n */
- msgset2( j, y+95, swk, col0);
- strmid(swk, headblk[1], 106, 7); /* -s */
- msgset2( j+16, y+105, swk, col0);
- strmid(swk, headblk[1], 114, 9); /* wrs 表示 */
- msgset2( j, y+115, swk, col0);
- /* strmid(swk, headblk[1], 176, 13); nasda landsat */
- /* msgset2( j, y+105, swk, col0); */
- /* strmid(swk, headblk[1], 189, 15); seen id */
- /* msgset2( j, y+105, swk, col0); */
- strmid(swk, headblk[1], 209, 8); /* sensor name */
- msgset2( j, y+125, swk, col0);
- fclose(fp);
- }
-
- recogmsg(x+350, y+115, col0);
- while (1) {
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (xychk(mx, my, x+350, y+115, x+350+33, y+115+18) == 1) {
- recogmsg(x+350, y+115, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x+350, y+115, x+350+33, y+115+18) == 0) {
- recogmsg(x+350, y+115, col0);
- continue;
- } else {
- break;
- }
- }
- }
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151, PSET);
- return;
-
- }
-
- void wabot(int x, int y, int sw)
- {
- int c1, c2, c4;
-
- if (sw == 0) {
- c1 = col1; c2 = col8; c4 = col7;
- } else {
- c1 = col8; c2 = col8; c4 = col15;
- }
- line(x+2, y+2, x+22, y+22, PSET, col0, 2, 0xffff);
- line(x, y, x+20, y+20, PSET, c4, 2, 0xffff);
- line(x, y, x+20, y+20, PSET, c2, 1, 0xffff);
- symbol(x+2, y+2, "WA", 1, 2, c1, 0, PSET);
- }
-
- int wabotchk( int mx, int my, int x, int y)
- {
-
- if (xychk16(mx, my, x, y) == 1) {
- wabot(x, y, 1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk16(mx, my, x, y) == 1) waexp();
- wabot(x, y, 0);
- return(1);
- }
- return(0);
- }
-
-
- /* mouse on off message if col < 0 then reverse */
- /* msg : 2char */
- void mousemsg(int x, int y, char *msg, int col)
- {
- if (col < 0) {
- line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col0, 2, 0xffff);
- msgset(x, y, msg, col15);
- } else {
- line(x-2, y-2, x+33, y+18, PSET, col, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
- msgset( x, y, msg, col);
- }
- }
-
- void execmsg(int x, int y, int col)
- {
- if (col < 0) {
- line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col0, 2, 0xffff);
- msgset(x, y, "実行", col15);
- } else {
- line(x-2, y-2, x+33, y+18, PSET, col, 1, 0xffff);
- line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
- msgset( x, y, "実行", col);
- }
- }
-
- void dcalcerr(int x, int y, int warea)
- {
- char msg[80];
-
- helpcls( x, y, x+390, y+120);
- if ( warea != 0 ) sprintf( msg, "作業領域 %d にエラーが発生しました。", warea);
- else sprintf( msg, "作業領域にエラーが発生しました。");
- msgset(x+16, y+50, msg, col10);
- msgset(x+16, y+70, "確認ボタンを押してください。", col10);
- recogin( x+300, y+90, 0);
- return;
- }
-
-
- /* com = A, com3 = B, com5 = out, com7 = calc type, abc[3]= work area */
- void datacalc2(int com, int com3, int com5, int com7, float abc[])
- {
- unsigned ddadr[2];
- unsigned char page;
- char buf[26206]; /* (397*132+7)/8*4 */
- int x, y, erflg = 0;
- int mx, my, mosx=400, mosy=100;
- int i, j, k, cx, cy, col, px, py;
- char swk[80];
- char wname1[64], wname2[64], wname3[64];
- FILE *fp1, *fp2, *fp3;
- unsigned char headblk[2][512], wblk1[1024], wblk2[1024], *blk1, *blk2;
- size_t bsize, bn;
- unsigned char huge *WPTR;
- float a, b, c, wfl;
-
- a = abc[0]; b = abc[1]; c = abc[2];
- sprintf(wname1, "%s\\warea%1d.lnd", workdir, com);
- sprintf(wname2, "%s\\warea%1d.lnd", workdir, com3);
- sprintf(wname3, "%s\\warea%1d.lnd", workdir, com5);
-
- x = 60; y = 100;
- page = 0;
- BSETDATAADR(ddadr, buf);
- GDS_getBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+131);
-
- helpbox( x, y, x+390, y+120, "演算");
- psmsgcls();
- msgset(96, 315, "画像間の演算処理を実行中です。", col0);
- switch (com7) {
- case 1 : strcpy(swk, "(axA)+(bxB)"); break;
- case 2 : strcpy(swk, "(axA)-(bxB)"); break;
- case 3 : strcpy(swk, "(axA)÷(bxB)"); break;
- case 4 : strcpy(swk, "(axA)x(bxB)"); break;
- case 5 : strcpy(swk, "(axA)+c"); break;
- case 6 : strcpy(swk, "(axA)-c"); break;
- case 7 : strcpy(swk, "(axA)÷c"); break;
- case 8 : strcpy(swk, "(axA)+c"); break;
- default : strcpy(swk, ""); break;
- }
- msgset(x+32, y+50, swk, col0);
- msgset(x+32, y+80, "計算中! しばらくお待ちください。", col0);
-
- /* work area open */
- if ((fp1 = fopen(wname1, "rb")) == NULL) {
- dcalcerr(x, y, com);
- goto dend;
- }
- bsize = 512; bn = 1;
- if (fread( headblk[0], bsize, bn, fp1) != bn) {
- fclose(fp1); dcalcerr(x, y, com);
- goto dend;
- }
- if (fread( headblk[1], bsize, bn, fp1) != bn) {
- fclose(fp1); dcalcerr(x, y, com);
- goto dend;
- }
-
- if (com7 < 5) {
- if ((fp2 = fopen(wname2, "rb")) == NULL) {
- fclose(fp1); dcalcerr(x, y, com3);
- goto dend;
- }
- bsize = 1024; bn = 1;
- if (fread( wblk1, bsize, bn, fp2) != bn) { /* ヘッダーよみとばし */
- fclose(fp1); fclose(fp2); dcalcerr(x, y, com3);
- goto dend;
- }
- }
-
- WPTR = WAREA;
- bsize = 512; bn = 1;
- for (i = 0; i < 400; i++) {
- /* 残量表示 */
- sprintf(swk, "%d", 400-i);
- line(x+16, y+30, x+48, y+46, PSET, col7, 2, 0xffff);
- symbol_(x+16, y+30, swk, 1, 1, col0, 0, PSET);
-
- blk1 = wblk1; blk2 = wblk2;
- if (fread( wblk1, bsize, bn, fp1) != bn) {
- fclose(fp1); if (com7 < 5) fclose(fp2);
- dcalcerr(x, y, com);
- goto dend;
- }
- if (com7 < 5) {
- if (fread( wblk2, bsize, bn, fp2) != bn) {
- fclose(fp1); fclose(fp2);
- dcalcerr(x, y, com3);
- goto dend;
- }
- }
-
- switch (com7) {
- case 1 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) + b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 2 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) - b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 3 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) / b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 4 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) * b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 5 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) + c) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 6 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) - c) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 7 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) / c) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- case 8 :
- for (j = 0; j < 512; j++) {
- if ((wfl = a*(*(blk1++)) * c) > 255) { *WPTR = 255; erflg = 1; }
- else if (wfl < 0) { *WPTR = 0; erflg = -1; }
- else { *WPTR = wfl; }
- WPTR++;
- }
- break;
- default :
- erflg = 9;
- *WPTR = 0;
- WPTR++;
- break;
- }
- }
- /* 計算終了 */
- fclose(fp1);
- if (com7 < 5) fclose(fp2);
-
- helpcls( x, y, x+390, y+120);
- if (erflg == 0) {
- msgset(x+16, y+30, "計算が正常に終了しました。", col0);
- } else {
- msgset(x+16, y+25, "計算が終了しました。計算結果データ中に", col0);
- msgset(x+16, y+45, "[0~255] の範囲を越えたものがあります。", col0);
- }
- if (recogin(x+300, y+95, 1) == 0) { /* 確認のときはcom5の作業領域にデータ格納 */
- msgset(x+16, y+65, "データを登録中です。お待ちください。", col0);
- /* work area open */
- if ((fp3 = fopen(wname3, "w+b")) == NULL) {
- fclose(fp3); dcalcerr(x, y, com5);
- goto dend;
- }
-
- switch (com7) {
- case 1 : strcpy(swk, "(axA)+(bxB)"); break;
- case 2 : strcpy(swk, "(axA)-(bxB)"); break;
- case 3 : strcpy(swk, "(axA)÷(bxB)"); break;
- case 4 : strcpy(swk, "(axA)x(bxB)"); break;
- case 5 : strcpy(swk, "(axA)+c"); break;
- case 6 : strcpy(swk, "(axA)-c"); break;
- case 7 : strcpy(swk, "(axA)÷c"); break;
- case 8 : strcpy(swk, "(axA)+c"); break;
- default : strcpy(swk, ""); break;
- }
-
- WPTR = WAREA;
- bsize = 512; bn = 1;
- /* header write */
- sprintf( headblk[0]+16, swk);
- bsize = 512; bn = 1;
- if (fwrite( headblk[0], bsize, bn, fp3) != bn) {
- fclose(fp3); dcalcerr(x, y, com5);
- goto dend;
- }
- if (fwrite( headblk[1], bsize, bn, fp3) != bn) {
- fclose(fp3); dcalcerr(x, y, com5);
- goto dend;
- }
-
- for ( i = 0; i < 400; i++) {
- for (j = 0; j < 512; j++) {
- wblk1[j] = *WPTR; WPTR++;
- }
- if (fwrite( wblk1, bsize, bn, fp3) != bn) {
- fclose(fp3); dcalcerr(x, y, com5);
- goto dend;
- }
- }
- fclose(fp3);
- }
-
- dend:
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+131, PSET);
- return;
- }
-
- void datacalcu()
- {
- int bcl[16];
- int exec, com, com2, com3, com4, com5, com6, com7, com8;
- int mx, my, mosx=400, mosy=100;
- int cx2, cy2;
- unsigned char page;
- double wa;
- float abc[3];
- char swk[80];
- int i;
-
- com = com2 = 1;
- com3 = com4 = 1;
- com5 = com6 = 1;
- com7 = com8 = 1;
- abc[0] = abc[1] = abc[2] = 1;
-
-
- page = 1;
- GDS_displayPage(page);
- gout();
- page = 0;
- GDS_writePage(page);
- gout();
-
- Cls;
- mttl();
- bcl[0] = col1;
- paint(1,30, 1, col7, 1, bcl);
- menubox( 80, 40, 560, 280, "画像間 四則演算");
- helpbox( 90, 65, 220, 150, "画像 A");
- helpbox(240, 65, 370, 150, "画像 B");
- helpbox(390, 65, 520, 150, "結果登録先");
- helpbox( 80,290, 560, 360, "メッセージ");
- msgset( 90, 90, " ○ 作業領域1", col0);
- msgset( 90,110, " ○ 作業領域2", col0);
- msgset( 90,130, " ○ 作業領域3", col0);
- msgset(240, 90, " ○ 作業領域1", col0);
- msgset(240,110, " ○ 作業領域2", col0);
- msgset(240,130, " ○ 作業領域3", col0);
- msgset(390, 90, " ○ 作業領域1", col0);
- msgset(390,110, " ○ 作業領域2", col0);
- msgset(390,130, " ○ 作業領域3", col0);
-
- msgset( 80,160, " ○ (a×A)+(b×B)", col0);
- msgset( 80,180, " ○ (a×A)-(b×B)", col0);
- msgset( 80,200, " ○ (a×A)÷(b×B)", col0);
- msgset( 80,220, " ○ (a×A)×(b×B)", col0);
- msgset(320,160, " ○ (a×A)+c", col0);
- msgset(320,180, " ○ (a×A)-c", col0);
- msgset(320,200, " ○ (a×A)÷c", col0);
- msgset(320,220, " ○ (a×A)×c", col0);
- msgset2( 80,240, " a=", col0);
- msgset2(112,240, "[ ]", col12);
- msgset2( 80,250, " b=", col0);
- msgset2(112,250, "[ ]", col12);
- msgset2( 80,260, " c=", col0);
- msgset2(112,260, "[ ]", col12);
- for (i = 0; i < 3; i++) {
- sprintf( swk, "%8.3f", abc[i]);
- msgset2( 128, 240+i*10, swk , col0);
- }
- msgset(320,240, " ○ 終 了", col0);
- execmsg(480, 260, col0);
- calcu(600, 30, 0);
- wabot(600, 60, 0);
-
- GDS_displayPage(page);
- gout();
- locate(0,0,COFF);
- MOS_disp(0);
- exec = 0;
-
- while(1) {
- if (com == 1) msgset(106, 90, "●", col0);
- if (com == 2) msgset(106,110, "●", col0);
- if (com == 3) msgset(106,130, "●", col0);
- if (com3 == 1) msgset(256, 90, "●", col0);
- if (com3 == 2) msgset(256,110, "●", col0);
- if (com3 == 3) msgset(256,130, "●", col0);
- if (com5 == 1) msgset(406, 90, "●", col0);
- if (com5 == 2) msgset(406,110, "●", col0);
- if (com5 == 3) msgset(406,130, "●", col0);
- if (com7 == 1) msgset( 96,160, "●", col0);
- if (com7 == 2) msgset( 96,180, "●", col0);
- if (com7 == 3) msgset( 96,200, "●", col0);
- if (com7 == 4) msgset( 96,220, "●", col0);
- if (com7 == 5) msgset(336,160, "●", col0);
- if (com7 == 6) msgset(336,180, "●", col0);
- if (com7 == 7) msgset(336,200, "●", col0);
- if (com7 == 8) msgset(336,220, "●", col0);
- if (com7 == 9) msgset(336,240, "●", col0);
-
- psmsgcls();
- if (com7 != 9) {
- msgset(96, 315, "画像データ(作業領域)間の四則演算をします。", col0);
- msgset(96, 335, "演算方法と定数を決定してから実行してください。", col0);
- } else {
- msgset(96, 315, "メイン・メニューにもどります。", col0);
- }
-
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
- if (wabotchk(mx, my, 600, 60) == 1) continue;
-
- for (i = 0; i < 3; i++) {
- if (xychk(mx, my,120,240+i*10, 120+80, 240+10+i*10) == 1) {
- line( 120, 240+i*10-1, 120+80, 240+10+i*10, PSET, col14, 1, 0xffff);
- cx2 = 250; cy2 = 125;
- psmsgcls();
- sprintf(swk, "定数 %c の値を入力してぐださい。", 'a'+i);
- msgset(96, 315, swk, col0);
- if (calc( &cx2, &cy2, &wa) == 1) {
- abc[i] = wa;
- sprintf( swk, "%8.3f", abc[i]);
- line( 120, 240+i*10-1, 120+80, 240+10+10*i, PSET, col7, 2, 0xffff);
- msgset2( 128, 240+i*10, swk , col0);
- } else {
- line( 120, 240+i*10-1, 120+80, 240+10+10*i, PSET, col7, 1, 0xffff);
- }
- psmsgcls();
- break;
- }
- }
-
- for (i = 0; i < 3; i++) {
- if (xychk16(mx, my, 106, 90+i*20) == 1) com = i+1;
- }
- for (i = 0; i < 3; i++) {
- if (xychk16(mx, my, 256, 90+i*20) == 1) com3 = i+1;
- }
- for (i = 0; i < 3; i++) {
- if (xychk16(mx, my, 406, 90+i*20) == 1) com5 = i+1;
- }
- for (i = 0; i < 4; i++) {
- if (xychk16(mx, my, 96, 160+i*20) == 1) com7 = i+1;
- }
- for (i = 0; i < 5; i++) {
- if (xychk16(mx, my, 336, 160+i*20) == 1) com7 = i+5;
- }
-
- if (xychk(mx, my,480, 260, 480+33, 260+18) == 1) {
- execmsg(480, 260, -1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my,480, 260, 480+33, 260+18) == 1) { /* 実行 */
- if (com7 != 9) {
- datacalc2(com, com3, com5, com7, abc); /* commnad, */
- } else { return; }
- }
- execmsg(480, 260, col0);
- continue;
- }
-
- if (com != com2) {
- msgset(106, 90+(com2-1)*20, "●", col7);
- msgset(106, 90+(com2-1)*20, "○", col0);
- com2 = com;
- }
-
- if (com3 != com4) {
- msgset(256, 90+(com4-1)*20, "●", col7);
- msgset(256, 90+(com4-1)*20, "○", col0);
- com4 = com3;
- }
-
- if (com5!= com6) {
- msgset(406, 90+(com6-1)*20, "●", col7);
- msgset(406, 90+(com6-1)*20, "○", col0);
- com6 = com5;
- }
-
- if (com7!= com8) {
- if (com8 < 5) {
- msgset( 96, 160+(com8-1)*20, "●", col7);
- msgset( 96, 160+(com8-1)*20, "○", col0);
- } else {
- msgset(336, 160+(com8-5)*20, "●", col7);
- msgset(336, 160+(com8-5)*20, "○", col0);
- }
- com8 = com7;
- }
- }
- }
-
-
- void hstmsg(int com)
- {
- char hmsg1[80], hmsg2[80];
- int col;
-
- hmsg1[0] = '\0'; hmsg2[0] = '\0';
-
- if (com == 7) {
- strcpy(hmsg1, "ヒストグラム\x095\x05c示をします。");
- /* 表 */
- strcpy(hmsg2, "作業領域を設定してください。");
- }
-
- if (com == 8) {
- strcpy(hmsg1, "1/4画像(256ピクセル×200ライン)のヒストグラム\x095\x05c示をします。");
- /* 表 */
- strcpy(hmsg2, "作業領域と画像\x095\x05c示開始点を設定してください。");
- } /* 表 */
-
- if (com == 10) {
- strcpy(hmsg1, "メイン・メニューにもどります。");
- }
-
- if (com == 21) {
- strcpy(hmsg1, "ライン開始点を設定してください。[ 1 ~ 201 ]");
- }
-
- if (com == 22) {
- strcpy(hmsg1, "ピクセル開始点を設定してください。[ 1 ~ 257 ]");
- }
- msgset(96, 315, hmsg1, col0);
- msgset(96, 335, hmsg2, col0);
- }
-
- void hststart(int lin, int pixel)
- {
- char swk[80];
- int x = 260, y = 200;
-
- helpbox( x, y, x+130, y+70, "\x095\x05c示開始点設定");
- /* 表 */
- sprintf( swk, "%4d ライン", lin);
- msgset( x+20, y+30, swk , col0);
- sprintf( swk, "%4d ピクセル", pixel);
- msgset( x+20, y+50, swk , col0);
- }
-
- void histgram2( int warea, int lin, int pixel, int mlin, int mpixel)
- {
- unsigned char page;
- int i, j, mx, my;
- char wname1[80];
- unsigned char headblk[2][512], wblk[512];
- size_t bsize, bn;
- FILE *fp1;
- char swk[80];
- long hstcnt[256], hstmax;
- int px, py;
-
- sprintf(wname1, "%s\\warea%1d.lnd", workdir, warea);
-
- page = 1;
- GDS_writePage(page);
- gout();
- Cls;
-
- helpbox2( 0, 0, 639, 109, "ヒストグラム\x095\x05c示");
- /* 表 */
- line( 0, 0, 639, 399, PSET, col1, 1, 0xffff);
- /* work area open */
- if ((fp1 = fopen(wname1, "rb")) == NULL) {
- GDS_displayPage(page);
- gout();
- pseudeerr(warea);
- goto end;
- }
- bsize = 512; bn = 1;
- if (fread( headblk[0], bsize, bn, fp1) != bn) {
- GDS_displayPage(page);
- gout();
- fclose(fp1); pseudeerr(warea); goto end;
- }
- if (fread( headblk[1], bsize, bn, fp1) != bn) {
- GDS_displayPage(page);
- gout();
- fclose(fp1); pseudeerr(warea); goto end;
- }
- sprintf(swk, "作業領域 %1d", warea);
- msgset(10, 25, swk, col0);
- strmid(swk, headblk[0]+16, 1, 15);
- msgset2(10, 45, swk, col0);
-
- sprintf(swk, "%dライン-%dピクセル/", lin, pixel);
- msgset2(10, 55, swk, col0);
- sprintf(swk, " %dライン-%dピクセル", lin+mlin-1, pixel+mpixel-1);
- msgset2(10, 65, swk, col0);
-
- strmid(swk, headblk[0]+32, 1, 15); /* band num */
- msgset2(10, 75, swk, col0);
-
- strmid(swk, headblk[1], 89, 7); /* date */
- msgset2(180, 25, swk, col0);
- strmid(swk, headblk[1], 97, 16); /* wrs seen sentor n-s */
- msgset2(180, 35, swk, col0);
- strmid(swk, headblk[1], 114, 9); /* wrs 表示 */
- msgset2(180, 45, swk, col0);
- strmid(swk, headblk[1], 176, 13); /* nasda landsat */
- msgset2(180, 55, swk, col0);
- strmid(swk, headblk[1], 189, 15); /* seen id */
- msgset2(180, 65, swk, col0);
- strmid(swk, headblk[1], 209, 8); /* sensor name */
- msgset2(180, 75, swk, col0);
-
- page = 1;
- GDS_displayPage(page);
- gout();
-
- msgset(25, 200, "頻", col14);
- msgset(25, 230, "度", col14);
- msgset(25-8, 260, "[%]", col14);
- msgset(25, 290, "↑", col14);
- msgset(10, 345, "強度→", col14);
- line( 75, 140, 600, 340, PSET, col13, 1, 0xffff);
- for (i = 0; i <= 250; i+=10) {
- line( 80+i*2, 340, 80+i*2, 340+3, PSET, col13, 0, 0xffff);
- sprintf(swk, "%3d", i);
- symbol(84+i*2, 340+5, swk, 1,1, col13, 3 ,PSET);
- /* line( 80+i*2, 140, 80+i*2, 140-3, PSET, col13, 0, 0xffff); */
- }
- line( 80+512, 340, 80+512, 340+3, PSET, col13, 0, 0xffff);
- symbol(84+255*2, 340+5, "255", 1,1, col13, 3, PSET);
- for (i = 0; i <= 100; i+=10) {
- line( 75, 340-i*2, 78, 340-i*2, PSET, col13, 0, 0xffff);
- line( 600, 340-i*2, 600-3, 340-i*2, PSET, col13, 0, 0xffff);
- sprintf(swk, "%3d", i);
- symbol(48, 340-4-i*2, swk, 1,1, col13, 0, PSET);
- }
-
-
- bsize = 512; bn = 1;
- if ((lin-1) != 0) {
- fseek(fp1, (long)(512.*(lin-1)), SEEK_CUR);
- }
- for (i = 0; i < 256; i++) hstcnt[i] = 0;
- for (py = lin; py < lin+mlin; py++) {
- if (fread( wblk, bsize, bn, fp1) != bn) {
- fclose(fp1);
- pseudeerr(0); goto end;
- }
-
- for (px = (pixel-1); px < pixel-1+mpixel; px++) {
- hstcnt[ wblk[px] ]++;
- }
- }
- fclose(fp1);
-
- hstmax = 0;
- for (i = 0; i < 256; i++) {
- if (hstmax < hstcnt[i]) hstmax = hstcnt[i];
- }
-
- for (i = 0; i < 256; i++) {
- j = 100. * hstcnt[i] / hstmax;
- line( 80+i*2, 340, 80+i*2, 340-j*2, OR, col5, 0, 0xffff);
- }
-
- while (recogin(550, 85, 0) != 0); /* 確認 */
-
- end:;
- page = 0;
- GDS_displayPage(page);
- gout();
- line( 550-2, 85-2, 550+40, 85+20, PSET, col7, 2, 0xffff); /* 確認メッセージ消去 */
- GDS_writePage(page);
- gout();
- return;
- }
-
-
- void histgram()
- {
- int bcl[16];
- int exec, com, com2, com3, com4;
- int mx, my, mosx=400, mosy=100;
- int cx2, cy2;
- unsigned char page;
- int lin = 1, pixel = 1, mlin, mpixel;
- double wa;
- char swk[80];
-
- com = com2 = 7;
- com3 = com4 = 1;
-
- start:
- page = 1;
- GDS_displayPage(page);
- gout();
- page = 0;
- GDS_writePage(page);
- gout();
-
- Cls;
- mttl();
- bcl[0] = col1;
- paint(1,30, 1, col7, 1, bcl);
- menubox( 80, 40, 560, 280, "ヒストグラム\x095\x05c示条件設定");
- /* 表 */
- helpbox( 80,290, 560, 360, "メッセージ");
- msgset( 80, 70, " ○ 作業領域1", col0);
- msgset( 80, 90, " ○ 作業領域2", col0);
- msgset( 80,110, " ○ 作業領域3", col0);
- msgset(320, 70, " ○ ヒストグラム\x095\x05c示", col0);
- /* 表 */
- msgset(320, 90, " ○ ヒストグラム\x095\x05c示(1/4)", col0);
- /* 表 */
- msgset(320,130, " ○ 終 了", col0);
- execmsg(480, 190, col0);
- if (com == 8) hststart(lin, pixel);
- calcu(600, 30, 0);
- wabot(600, 60, 0);
- GDS_displayPage(page);
- gout();
- locate(0,0,COFF);
- MOS_disp(0);
- exec = 0;
-
- while(1) {
- if (com3 == 1) msgset( 96, 70, "●", col0);
- if (com3 == 2) msgset( 96, 90, "●", col0);
- if (com3 == 3) msgset( 96,110, "●", col0);
- if (com == 7) msgset(336, 70, "●", col0);
- if (com == 8) msgset(336, 90, "●", col0);
- if (com ==10) msgset(336,130, "●", col0);
- hstmsg(com);
-
- if (exec == 1) {
- if (com == 7 || com == 8) {
- if (com == 7) {
- lin = 1; pixel = 1; mlin = 400; mpixel = 512;
- } else {
- mlin = 200; mpixel = 256;
- }
- histgram2(com3, lin, pixel, mlin, mpixel); /* commnad, work area, start line, start pixel, max line, max pixel */
- execmsg(480, 190, col0);
- psmsgcls();
- exec = 0;
- continue;
- }
- if (com == 10) { return; }
- }
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
- if (wabotchk(mx, my, 600, 60) == 1) continue;
- if ((xychk(mx, my,280-2,230-2, 280+33, 230+18) == 1) && com != 7) {
- line( 280-2,230-2, 280+33, 230+18, PSET, col14, 1, 0xffff);
- cx2 = 105; cy2 = 125;
- psmsgcls();
- hstmsg(21);
- wa = lin;
- if (calc( &cx2, &cy2, &wa) == 1) {
- if (wa < 1 ) lin = 1;
- else if (wa > 201) lin = 201;
- else lin = wa;
- sprintf( swk, "%4d", lin);
- line( 280-2,230-2, 280+33, 230+18, PSET, col7, 2, 0xffff);
- msgset( 280, 230, swk , col0);
- } else {
- line( 280-2,230-2, 280+33, 230+18, PSET, col7, 1, 0xffff);
- }
- psmsgcls();
- }
- if ((xychk(mx, my,280-2,250-2, 280+33, 250+18) == 1) && com != 7) {
- line( 280-2,250-2, 280+33, 250+18, PSET, col14, 1, 0xffff);
- cx2 = 105; cy2 = 125;
- psmsgcls();
- dithmsg(22, 1);
- wa = pixel;
- if (calc( &cx2, &cy2, &wa) == 1) {
- if (wa < 1 ) pixel = 1;
- else if (wa > 257) pixel = 257;
- else pixel = wa;
- sprintf( swk, "%4d", pixel);
- line( 280-2,250-2, 280+33, 250+18, PSET, col7, 2, 0xffff);
- msgset( 280, 250, swk , col0);
- } else {
- line( 280-2,250-2, 280+33, 250+18, PSET, col7, 1, 0xffff);
- }
- psmsgcls();
- }
-
- if (xychk16(mx, my, 96, 70) == 1) com3 = 1;
- if (xychk16(mx, my, 96, 90) == 1) com3 = 2;
- if (xychk16(mx, my, 96,110) == 1) com3 = 3;
- if (xychk16(mx, my,336, 70) == 1) com = 7;
- if (xychk16(mx, my,336, 90) == 1) com = 8;
- if (xychk16(mx, my,336,130) == 1) com =10;
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- execmsg(480, 190, -1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- exec = 1;
- continue;
- } else {
- exec = 0;
- execmsg(480, 190, col0);
- continue;
- }
- }
- if (com3 != com4) {
- if (com4 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
- if (com4 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
- if (com4 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
- com4 = com3;
- }
- if (com != com2) {
- if (com2 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
- if (com2 == 8) { msgset(336, 90, "●", col7); msgset(336, 90, "○", col0); }
- if (com2 ==10) { msgset(336,130, "●", col7); msgset(336,130, "○", col0); }
- if (com == 7) line( 260,200, 390+10, 270+8, PSET, col7, 2, 0xffff);
- if (com == 8) hststart(lin, pixel);
- psmsgcls();
- com2 = com;
- }
- /* 裏画面表示 */
- backexp(mx, my, 630, 0, 639, 20);
- continue;
- }
- }
-
- /* no operation */
- void nop()
- {
- unsigned ddadr[2];
- unsigned char page;
- char buf[30175]; /* (397*152+7)/8*4 */
- int x, y, com;
- int mx, my;
-
- x = 60; y = 65;
- page = 0;
- BSETDATAADR(ddadr, buf);
- GDS_getBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151);
-
- helpbox( x, y, x+390, y+120, "NOP・メニュー");
- msgset(x, y+50, " まだ何もないよ!", col0);
-
- recogmsg(x+350, y+95, col0);
- while (1) {
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 1) {
- recogmsg(x+350, y+95, -1);
- while((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 0) {
- recogmsg(x+350, y+95, col0);
- continue;
- } else {
- break;
- }
- }
- }
- GDS_putBlock(ddadr[0], ddadr[1], page, x, y, x+396, y+151, PSET);
- return;
-
- }
-
- void hmsgset(int com, int sw)
- {
- char hmsg1[80], hmsg2[80];
- int col;
-
- hmsg1[0] = '\0'; hmsg2[0] = '\0';
-
- if (com == 0) {
- strcpy(hmsg1, "本プログラムを終了します。");
- strcpy(hmsg2, "失われるデータがあるか、確認して下さい。");
- }
-
- if (com == 11) {
- strcpy(hmsg1, "MS-DOSモードになります。");
- strcpy(hmsg2, "EXIT〔改行〕で戻ります。");
- }
-
- if (com == 1) {
- strcpy(hmsg1, "観測データ・フロッピー(IBMフォーマット)から");
- strcpy(hmsg2, "作業領域へデータを読み込みます。");
- }
-
- if (com == 2) {
- strcpy(hmsg1, "作業領域内のデータを退避または復帰します。");
- }
-
- if (com == 3) {
- strcpy(hmsg1, "作業領域内のデータ間で各種の演算処理をします。");
- }
-
- if (com == 4) {
- strcpy(hmsg1, "作業領域内のデータをヒストグラム\x095\x05c示します。");
- } /* 表 */
-
- if (com == 5) {
- strcpy(hmsg1, "作業領域内のデータをシュード・カラー画像\x095\x05c示します。");
- } /* 表 */
-
- if (com == 6) {
- strcpy(hmsg1, "作業領域内のデータをディザ・カラー画像\x095\x05c示します。");
- } /* 表 */
-
- if (com == 7) {
- strcpy(hmsg1, "拡張用です。");
- }
-
- if (sw == 0) col = col7;
- else col = col0;
-
- msgset(96, 255, hmsg1, col);
- msgset(96, 275, hmsg2, col);
- }
-
- /* ex. landsat [a:] [1] */
- main(int argc, char *argv[])
- {
- int datadrive;
- int x, y, bcl[16];
- int mx, my, com, com2, exec, mosx=400, mosy=100;
- unsigned char page;
- double wa = 0;
- int i;
-
- strcpy( workdir, "a:");
- datadrive = 1;
-
- /* work dir or data drive set */
- for ( i=1; i < argc; i++) {
- ++argv;
- if (( 'a' <= **argv && **argv <= 'z') || ( 'A' <= **argv && **argv <= 'Z')) {
- strcpy( workdir, *argv);
- }
- if ( '0' <= **argv && **argv <= '3') {
- datadrive = atoi( *argv);
- }
- }
-
- init();
- color(7, 0);
- Cls;
- /*
- system("tifl land");
- */
- /*
- printf("%d\n", tiffl(0,0, "land2.tif"));
- */
- com = 1; com2 = com;
- while(1) {
- page = 1;
- GDS_writePage(page);
- gout();
- Cls;
- GDS_displayPage(page);
- gout();
- page = 0;
- GDS_writePage(page);
- gout();
- Cls;
- mttl();
- bcl[0] = col1;
- paint(1,30, 1, col7, 1, bcl);
- menubox( 80, 40, 560, 220, "メインメニュー");
- helpbox( 80,230, 560, 300, "コマンド説明");
-
- msgset( 80, 70, " ○ データ読み込み", col0);
- msgset( 80, 90, " ○ 作業領域の退避・復帰", col0);
- msgset( 80,110, " ○ 画像間 四則演算", col0);
- msgset( 80,130, " ○ ヒストグラム\x095\x05c示", col0);
- /* 表 */
- msgset( 80,150, " ○ シュードカラー画像\x095\x05c示", col0);
- /* 表 */
- msgset( 80,170, " ○ ディザカラー画像\x095\x05c示", col0);
- /* 表 */
- /* msgset(320, 70, " ○ 三次元画像\x095\x05c示", col0); */
- /* 表 */
- msgset(320, 70, " ○ * * *", col0);
- msgset(320,150, " ○ MS-DOS", col0);
- msgset(320,170, " ○ 終 了", col0);
- execmsg(480, 190, col0);
- calcu(600, 30, 0);
- wabot(600, 60, 0);
- exec = 0;
- GDS_displayPage(page);
- gout();
- locate(0,0,COFF);
- MOS_disp(0);
- while(1) {
- if (com == 1) msgset( 96, 70, "●", col0);
- if (com == 2) msgset( 96, 90, "●", col0);
- if (com == 3) msgset( 96,110, "●", col0);
- if (com == 4) msgset( 96,130, "●", col0);
- if (com == 5) msgset( 96,150, "●", col0);
- if (com == 6) msgset( 96,170, "●", col0);
- if (com == 7) msgset(336, 70, "●", col0);
- if (com ==11) msgset(336,150, "●", col0);
- if (com == 0) msgset(336,170, "●", col0);
- hmsgset(com, 1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (exec == 1) {
- if (com == 1) { dataset(datadrive); break; }
- if (com == 2) { datasave(); break; }
- if (com == 3) { datacalcu(); break; }
- if (com == 4) { histgram(); break; }
- if (com == 5) { pseude(); break; }
- if (com == 6) { dither(); break; }
- if (com == 7) {
- nop(); exec = 0; execmsg(480, 190, col0);
- continue;
- }
- if (com ==11) { deinit(); system("command.com"); init(); break; }
- if (com == 0) { deinit(); exit(0); }
- }
- while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
- if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
- if (wabotchk(mx, my, 600, 60) == 1) continue;
- if (xychk16(mx, my, 96, 70) == 1) com = 1;
- if (xychk16(mx, my, 96, 90) == 1) com = 2;
- if (xychk16(mx, my, 96,110) == 1) com = 3;
- if (xychk16(mx, my, 96,130) == 1) com = 4;
- if (xychk16(mx, my, 96,150) == 1) com = 5;
- if (xychk16(mx, my, 96,170) == 1) com = 6;
- if (xychk16(mx, my,336, 70) == 1) com = 7;
- if (xychk16(mx, my,336,150) == 1) com =11;
- if (xychk16(mx, my,336,170) == 1) com = 0;
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- execmsg(480, 190, -1);
- while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
- if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
- exec = 1;
- continue;
- } else {
- exec = 0;
- execmsg(480, 190, col0);
- continue;
- }
- }
- if (com != com2) {
- if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
- if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
- if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
- if (com2 == 4) { msgset( 96,130, "●", col7); msgset( 96,130, "○", col0); }
- if (com2 == 5) { msgset( 96,150, "●", col7); msgset( 96,150, "○", col0); }
- if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
- if (com2 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
- if (com2 ==11) { msgset(336,150, "●", col7); msgset(336,150, "○", col0); }
- if (com2 == 0) { msgset(336,170, "●", col7); msgset(336,170, "○", col0); }
- hmsgset(com2, 0);
- com2 = com;
- }
- }
- }
- }
-